package com.gs.wzmanager.service.impl;

import com.gs.wzmanager.bo.Threshold;
import com.gs.wzmanager.dao.ForeThresholdDao;
import com.gs.wzmanager.entity.ForeThreshold;
import com.gs.wzmanager.service.ForeThresholdService;
import com.gs.wzmanager.utils.HttpUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ForeThresholdServiceImpl implements ForeThresholdService {

    @Autowired
    ForeThresholdDao dao;

    @Override
    public ResponseEntity add(ForeThreshold foreThreshold) {
        if (dao.add(foreThreshold)) {
            return HttpUtils.buildStringResponse("OK", HttpStatus.OK);
        }
        return null;
    }

    @Override
    public List<ForeThreshold> queryForeThresholdByStationName(String stationName) {
        return dao.queryForeThresholdByStationName(stationName);
    }

    @Override
    public ResponseEntity update(ForeThreshold foreThreshold) {
        if (dao.update(foreThreshold)) {
            return HttpUtils.buildStringResponse("OK", HttpStatus.OK);
        }
        return null;
    }

    @Override
    public ResponseEntity delete(int id) {
        if (dao.delete(id)) {
            return HttpUtils.buildStringResponse("OK", HttpStatus.OK);
        }
        return null;
    }

    @Override
    public List<Threshold> queryThreshold() {
        return dao.queryThreshold();
    }
}
